<template>
  <el-sub-menu v-if="menu.type === 'M'" :index="menu.id.toString()">
    <template #title>
      <el-icon v-if="menu.icon"><component :is="menu.icon"/></el-icon>
      <span>{{ menu.name }}</span>
    </template>
    <menu-item v-for="item in menu.children" :key="item.id" :menu="item"/>
  </el-sub-menu>
  <el-menu-item v-else-if="menu.type === 'C'" :index="menu.path[0] === '/' ? menu.path : '/' + menu.path">
    <el-icon v-if="menu.icon"><component :is="menu.icon"/></el-icon>
    <span>{{ menu.name }}</span>
  </el-menu-item>
</template>

<script setup>
import MenuItem from '@/components/MenuItem'

defineProps({
  menu: Object
})
</script>

<style scoped>

</style>
